package javango.contrib.hibernate;

import org.hibernate.Criteria;
import org.hibernate.Interceptor;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import com.google.inject.ImplementedBy;

/**
 * Basic Hibernate helper class, handles SessionFactory, Session and Transaction.
 * <p>
 * Uses a  initializer for the initial SessionFactory creation
 * and holds Session and Transactions in thread local variables. All
 * exceptions are wrapped in an unchecked DaoException.
 *
 * @author johns
 */

@ImplementedBy(HibernateUtilImpl.class)
public interface HibernateUtil {
	SessionFactory getSessionFactory();
	AnnotationConfiguration getConfiguration();
	Session getSession()	throws DaoException;
	void closeSession() throws DaoException;
	void beginTransaction()
		throws DaoException ;
	void commitTransaction()
		throws DaoException ;
	void rollbackTransaction()
		throws DaoException;
	int doCount(Criteria c) throws DaoException ;
	Interceptor getInterceptor();
	void setInterceptor(Interceptor interceptor);
}
